import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;

public class EnableSound extends Canvas {

	private static final int BGR_COLOR = 0x3A79FF;
	private static final String QUESTION = "ENABLE SOUND?";
	private static final String YES = "YES";
	private static final String NO = "NO";

	private Rectangle yes;
	private Rectangle no;

	private int width, height;

	private Display display;
	private Displayable next;

	public EnableSound(Display display, AppMidlet app) {
		this.display = display;
		next = new MenuCanvas(display, app);

		setFullScreenMode(true);
		width = getWidth();
		height = getHeight();

		yes = new Rectangle(5, height - 2 - ThemeManager.Big.pieceHeight,
				ThemeManager.Big.maxWidth * YES.length(),
				ThemeManager.Big.pieceHeight);

		int temp = ThemeManager.Big.maxWidth * NO.length();
		no = new Rectangle(width - temp - 3, yes.y, temp, yes.height);
	}

	private void goNext() {
		display.setCurrent(next);
	}

	protected void keyPressed(int keyCode) {
		if (keyCode == -7) {
			Option.isSound = false;
		}
		goNext();
	}

	protected void pointerPressed(int x, int y) {
		if (yes.inside(x, y)) {
			goNext();
		} else if (no.inside(x, y)) {
			Option.isSound = false;
			goNext();
		}
	}

	protected void paint(Graphics g) {
		g.setColor(BGR_COLOR);
		g.fillRect(0, 0, width, height);
		ThemeManager.drawStringCenter(g, QUESTION, width, height / 2,
				ThemeManager.BIG_STYLE, Graphics.VCENTER);
		ThemeManager.drawString(g, YES, yes.x, yes.y, ThemeManager.BIG_STYLE,
				Graphics.TOP);
		ThemeManager.drawString(g, NO, no.x, no.y, ThemeManager.BIG_STYLE,
				Graphics.TOP);
	}

}
